﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AddIn.EA.Architecture.ComponentLogic;
using AddIn.EA.Architecture.Presentation.Interfaces;

namespace AddIn.EA.Architecture.Presentation.Controls
{
    public partial class BEMain : UserControl, IAddNewBusinessEntity
    {
        private BusinessEntity _entity;

        public BEMain()
        {
            InitializeComponent();
            ucWizard.UpdateEA += new Action(ucWizard_UpdateEA);
        }

        void ucWizard_UpdateEA()
        {
            if (this.UpdateEA != null)
                this.UpdateEA();
        }

        public event Action UpdateEA;

        private IAddNewBusinessEntity AddNewBusinessEntity
        {
            get 
            {
                try
                {
                    return ((IAddNewBusinessEntity)this.Parent);
                }
                catch { return null; }
            }
        }

        #region IAddNewBusinessEntity Members

        public BusinessEntity Entity
        {
            get
            {
                if (_entity == null && this.AddNewBusinessEntity != null)
                    _entity = this.AddNewBusinessEntity.Entity;

                return _entity;
            }
            set
            {
                _entity = value;
            }
        }

        public void RefreshEntity()
        {
            ucTreeView.RefreshEntity();
        }
        #endregion
    }
}
